#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=50000;

int max(int a, int b) {
  return a>b ? a : b;
}

int solve(int x, char *a, char *b) {
  static int p[maxn+1];
  p[0]=0;
  for (int i=1, t; a[i]!='\0'; i++) {
    for (t=p[i-1]; t && t+1!=x && a[t+1]!=a[i]; t=p[t]);
    if ((t+1==x || a[t+1]==a[i]) && t+1<i) {
      p[i]=t+1;
    } else {
      p[i]=0;
    }
  }

  int ans=0;
  for (int i=1, j=0; b[i]!='\0'; i++) {
    for (; j && j+1!=x && a[j+1]!=b[i]; j=p[j]);
    if (j+1==x || a[j+1]==b[i]) {
      j++;
    }
    ans = max(ans, j);
  }
  return ans;
}

int main() {
#ifdef DEBUG
  freopen("0.in", "r", stdin);
  freopen("0.out", "w", stdout);
#endif

  char a[maxn+2], b[maxn+2];
  scanf("%s %s", a+1, b+1);

  a[0]='*';
  int ans=0;
  for (int i=0; a[i]!='\0'; i++) {
    ans = max(ans, solve(i, a, b));
  }
  printf("%d", ans);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
